/**
 * @Author: Sagan
 * @Date: 2020/09/19 14:07
 */
package function

import "regexp"

func regMatch(v, reg string) bool {
	if "" == v {
		return false
	}

	return regexp.MustCompile(reg).MatchString(v)
}

func Email(v string) bool {
	return regMatch(v, `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`)
}

func Alpha(v string) bool {
	return regMatch(v, `^[a-zA-Z]+$`)
}

func AlphaNum(v string) bool {
	return regMatch(v, `^[a-zA-Z0-9]+$`)
}

func AlphaDash(v string) bool {
	return regMatch(v, `^[a-zA-Z0-9_-]+$`)
}
